package com.shawn.model.vo;

import cn.hutool.core.util.RandomUtil;
import com.shawn.model.entity.UserInfo;
import com.shawn.model.mongo.RecommendUser;
import com.shawn.model.mongo.UserLike;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

/**
 * 粉丝及关注及相互关注信息
 *
 * @author lenovo
 * @date 2022/11/02
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class RelationUserInfoVo {
    private Integer id; //用户id 1
    private String nickname; //昵称
    private String avatar; //用户头像
    private String gender; //性别
    private Integer age; //年龄
    private String city; //城市
    private String education; //学历
    private Integer marriage; //婚姻状态
    private String coverPic; // 封面图片

    private Integer matchRate;//匹配度
    private Boolean alreadyLove;//是否喜欢她

    public static RelationUserInfoVo init(UserInfo uif, RecommendUser rec, UserLike userLike){
        RelationUserInfoVo vo = new RelationUserInfoVo();
        BeanUtils.copyProperties(uif,vo);
        vo.setId(Math.toIntExact(uif.getId()));
        if (rec==null){
            vo.setMatchRate(RandomUtil.randomInt(50,99));
        }else {
            vo.setMatchRate(rec.getScore().intValue());
        }
        if (userLike==null){
            vo.setAlreadyLove(false);
        }else {
            vo.setAlreadyLove(userLike.getIsLike());
        }

        return vo;
    }
}
